package com.zt.securityTest.controller;

import com.zt.securityTest.common.R;
import com.zt.securityTest.common.ResultCode;
import com.zt.securityTest.entity.User;
import com.zt.securityTest.service.UserService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

import static com.zt.securityTest.common.ResultCode.*;

/**
 * time: 2024.11.16 11:43
 */
@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public R login(@RequestBody User user) {
        return userService.login(user);
    }

    @PostMapping("/logout")
    public R logout(HttpServletRequest request, HttpServletResponse response){
        return userService.logout(request,response);
    }
}
